<form id="addOrUpdateForm" lay-filter="addOrUpdateForm" class="layui-form model-form">

    <input name="id" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label layui-form-required">专家姓名</label>
        <div class="layui-input-block">
            <input name="name" class="layui-input" placeholder="请输入专家姓名" lay-verType="tips" lay-verify="required" required/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label layui-form-required">专家年龄</label>
        <div class="layui-input-block">
            <input name="age" class="layui-input" placeholder="请输入专家年龄" lay-verType="tips" lay-verify="required" required/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label layui-form-required">专家性别</label>
        <div class="layui-input-block">
            <div id="sexId"></div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label layui-form-required">部职别</label>
        <div class="layui-input-block">
            <input name="departmentPosition" class="layui-input" placeholder="请输入部职别" lay-verType="tips"/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">擅长领域</label>
        <div class="layui-input-block">
            <input name="field" class="layui-input" placeholder="请输入擅长领域" lay-verType="tips"  />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">工作时间</label>
        <div class="layui-input-block">
            <input type="text" name="workTime" id="workTimeId" placeholder="请选择工作时间" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">工作地点</label>
        <div class="layui-input-block">
            <input name="workAddress" class="layui-input" placeholder="请输入工作地点" lay-verType="tips"/>
        </div>
    </div>

   <!-- <div class="layui-form-item">
        <label class="layui-form-label layui-form-required">预约状态</label>
        <div class="layui-input-block">
            <div id="statusId"></div>
        </div>
    </div>-->

    <div class="layui-form-item">
        <label class="layui-form-label">其他</label>
        <div class="layui-input-block">
            <input name="other" class="layui-input" placeholder="请输入其他" lay-verType="tips"/>
        </div>
    </div>

    <div class="layui-form-item text-right">
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        <button class="layui-btn" lay-filter="formSubmitBtn" lay-submit>保存</button>
    </div>
</form>

<script>
    layui.use(['layer', 'form', 'admin', 'xnUtil', 'xmSelect', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
        var xnUtil = layui.xnUtil;
        var xmSelect = layui.xmSelect;
        var laydate = layui.laydate;

        var sexRadio = '';
        var sexRadioData = xnUtil.getDictDataByDictTypeCode('sex', null);
        sexRadioData.forEach(function (item) {
            sexRadio = sexRadio + '<input type="radio" name="sex" value="'+item.code+'" title="'+item.name+'">'
        })
        $("#sexId").html(sexRadio)
        form.render('radio');

        laydate.render({
            elem: '#workTimeId'
        });
        // var statusRadio = '';
        // var statusRadioData = xnUtil.getDictDataByDictTypeCode('common_status', null);
        // statusRadioData.forEach(function (item) {
        //     statusRadio = statusRadio + '<input type="radio" name="status" value="'+item.code+'" title="'+item.name+'">'
        // })
        // $("#statusId").html(statusRadio)
        // form.render('radio');


        var editData = admin.getLayerData('#addOrUpdateForm').data;
        if(editData !== null && editData !== undefined) {
            form.val('addOrUpdateForm', editData);
        }

        /**
         * 表单提交事件
         */
        form.on('submit(formSubmitBtn)', function (data) {
            layer.load(2);

            var url = editData ? getProjectUrl() + 'sysExpertReservation/edit' : getProjectUrl() + 'sysExpertReservation/add';
            admin.req(url, JSON.stringify(data.field), function(res){
                layer.msg(res.message, {icon: 1, time: 1000}, function () {
                    admin.putLayerData('formOk', true, '#addOrUpdateForm');
                    admin.closeDialog('#addOrUpdateForm');
                });
            }, 'post');
            return false;
        });
    });
</script>
</body>
</html>
